import http from './index'
import qs from 'qs'

export function menuADD(data) {
    return http.post('/menuadd', qs.stringify(data))
}

export function menuList(params) {
    return http.get('/menulist', {
        params
    })
}
//封装了一个菜单删除接口
export function menuDel(data) {
    return http.post('/menudelete', qs.stringify(data))
}

//封装一个菜单获取（一条）
export function menuInfo(params) {
    return http.get('/menuinfo', {
        params
    })
}
//封装了一个菜单编辑
export function menuEdit(data) {
    return http.post('/menuedit', qs.stringify(data))
}

//角色接口封装

export function roleAdd(data) {
    return http.post('/roleadd', qs.stringify(data))
}
//封装一个列表渲染接口
export function roleList() {
    return http.get('/rolelist')
}
//封装了一个角色删除接口
export function roleDel(data) {
    return http.post('/roledelete', qs.stringify(data))
}
//封装一个角色获取（一条）
export function roleInfo(params) {
    return http.get('/roleinfo', {
        params
    })
}
//封装了一个角色编辑
export function roleEdit(data) {
    return http.post('/roleedit', qs.stringify(data))
}

//管理员管理封装
export function userAdd(data) {
    return http.post('/useradd', qs.stringify(data))
}

export function userList(params) {
    return http.get('/userlist', {
        params
    })
}
export function userDel(data) {
    return http.post('/userdelete', qs.stringify(data))
}
export function userInfo(params) {
    return http.get('/userinfo', {
        params
    })
}
export function userEdit(data) {
    return http.post('/useredit', qs.stringify(data))
}
export function userCount() {
    return http.get('/usercount')
}
export function userLogin(data) {
    return http.post('/userlogin', qs.stringify(data))
}

// 商品分类
// 添加
export function cateAdd(data) {
    let file = new FormData();
    for (let i in data) {
        file.append(i, data[i])
    }
    return http.post('/cateadd', file)
}
// 列表数据
export function cateList() {
    return http.get('/catelist', {
        params: {
            istree: true,
        }
    })
}
// 一条数据

export function cateInfo(params) {
    return http.get('/cateinfo', {
        params
    })
}

//分类修改
export function cateEdit(data) {
    let file = new FormData();
    for (let i in data) {
        file.append(i, data[i]);
    }
    return http.post('/cateedit', file)
}
//分类删除
export function cateDelete(data) {
    return http.post('/catedelete', qs.stringify(data))
}

// 商品规格管理
// 添加
export function specsAdd(data) {
    return http.post('/specsadd', data)
}
// 列表数据
export function specsList(params) {
    return http.get('/specslist', {
        params
    })
}
// 一条数据

export function specsInfo(params) {
    return http.get('/specsinfo', {
        params
    })
}

//分类修改
export function specsEdit(data) {
    return http.post('/specsedit', data)
}
//分类删除
export function specsDelete(data) {
    return http.post('/specsdelete', data)
}

// 管理总数
export function specsCount() {
    return http.get('/specscount')
}

// 商品管理
export function goodsAdd(data) {
    let file = new FormData();
    for (let i in data) {
        file.append(i, data[i]);
    }
    return http.post("/goodsadd", file);
}
//商品管理列表
export function goodsList(params) {
    return http.get("/goodslist", {
        params,
    });
}
// 一条数据

export function goodsInfo(params) {
    return http.get('/goodsinfo', {
        params
    })
}

//分类修改
export function goodsEdit(data) {
    let file = new FormData();
    for (let i in data) {
        file.append(i, data[i]);
    }
    return http.post('/goodsedit', file)
}
//分类删除
export function goodsDelete(data) {
    return http.post('/goodsdelete', data)
}

// 管理总数
export function goodsCount() {
    return http.get('/goodscount')
}

// 轮播图接口
export function banneradd(data) {
    return http.post("/banneradd", data);
}

export function banneredit(data) {
    return http.post("/banneredit", data);
}

export function bannerdelete(data) {
    return http.post("/bannerdelete", data);
}

export function bannerlist() {
    return http.get("/bannerlist");
}

export function bannerinfo(params) {
    return http.get("/bannerinfo", {
        params,
    });
}

// 封装会员接口

export function memberList() {
    return http.get("/memberlist");
}

export function memberEdit(data) {
    return http.post("/memberedit", data);
}

export function memberInfo(params) {
    return http.get("/memberinfo", {
        params,
    });
}

//限时秒杀
export function seckAdd(data) {
    return http.post("/seckadd", data);
}

export function seckList() {
    return http.get("/secklist");
}
//封装限时秒杀获取（一条）接口
export function seckInfo(params) {
    return http.get("/seckinfo", {
        params,
    });
}
//封装限时秒杀修改接口
export function seckEdit(data) {
    return http.post("/seckedit", data);
}
//封装限时秒杀删除接口
export function seckDelete(data) {
    return http.post("/seckdelete", data);
}
